package org.jactao.remote.netty;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.jactao.common.LResponse;
import org.jactao.rpc.LResponseHolder;

/**
 * Created by fanzetao on 2018/4/3.
 */
public class NettyClientHandler extends SimpleChannelInboundHandler<LResponse> {

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
    }

    @Override
    public void channelRead0(ChannelHandlerContext ctx, LResponse msg) throws Exception {
        LResponseHolder.get().get(msg.getRequestId()).setResponse(msg);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        cause.printStackTrace();
    }

}
